<?php
namespace App\Services\Business\Business;

use App\Models\Business\Business;
use App\Services\Manage\ManageIndex;
use Illuminate\Support\Facades\DB;

/**
 * 业务微应用逻辑层
 * Class ArticleLogic
 * @package App\Services\Article\Article
 */
class BusinessLogic
{
    /**
     * 业务添加
     * @return array
     */
    public function add($data)
    {
        $rst = Business::insertGetId($data);
        if ($rst === false) {
            return auto_failure($data, '业务添加失败！');
        } elseif ($rst === 0) {
            return auto_failure($data, '业务未作改动！');
        }
        return auto_return(['id' => $rst], '添加成功！');
    }

    /**
     * 删除业务
     * @param $data
     * @return array
     */
    public function delete($data)
    {
        $rst = Business::where($data)
            ->update($updateData);
        if ($rst === false) {
            return auto_failure($data, '文章状态更改失败！');
        } elseif ($rst === 0) {
            return auto_failure($data, '文章状态未发生修改！');
        }
        return auto_return(['number' => $rst], '文章已删除！');
    }

    /**
     * 业务列表
     * @param $data
     * @return array
     */
    public function businessList($data)
    {
        $list = Business::select()->paginate(10);

        return auto_success($list, '成功获取业务列表', '获取业务列表失败');
    }

}